package com.ruoyi.util.paypassword;

import com.ruoyi.system.domain.PayInfo;
import com.ruoyi.system.mapper.PayInfoMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Objects;

@Service
public class PasswordService {

    @Resource
    private PayInfoMapper payInfoMapper;
    public boolean payPassword(String password,Long senderId) {
        PayInfo payInfo = payInfoMapper.selectPayInfoByUserId(senderId);
        return Objects.equals(payInfo.getPayPassword(), password);
    }
    public boolean passwordVerifiers (String password) {
        if (password == null || password.length() != 6) {
            return false;
        }
        // 定义正则表达式
        String regex = "^(?!(\\d)\\1{5}$)(?!(\\d)\\2{1,5}$)\\d{6}$";
        // 使用正则表达式进行匹配
        return password.matches(regex);
    }
}